package com.teamwhole.modules.sys.web;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.teamwhole.modules.sys.entity.BaseCode;
import com.teamwhole.modules.sys.service.BaseCodeService;

@Component
@Path("/sys/basecode")
@Consumes("application/json;charset=utf-8")
@Produces("application/json;charset=utf-8")
public class BaseCodeResource {
	
	@Autowired
    private BaseCodeService baseCodeService;
	
	@Path("/get")
	@GET
	public List<BaseCode> get(@QueryParam("classCode") String classCode) {
		return baseCodeService.getBaseCodeList(classCode);
	}
	
	@Path("/getAll")
	@GET
	public List<BaseCode> getAll(@QueryParam("classCode") String classCode) {
		System.out.println(classCode);
		return baseCodeService.getAllBaseCodeList(classCode);
	}
	
	@Path("/list_tree")
	@POST
	public List<BaseCode> getTree(BaseCode entity) {
		if (StringUtils.isBlank(entity.getId())) {
			entity.setId("0");
		}
		return baseCodeService.findNextLevel(entity);
	}
}
